﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Slf;

namespace SLF.Test.Log_Items
{
  /// <summary>
  /// Summary description for Given_Log_Item
  /// </summary>
  [TestClass]
  public class Given_Log_Item
  {
    [TestMethod]
    public void Cloning_Items_Should_Create_Exact_Copy()
    {
      LogItem item = new LogItem();
      item.EventId = 999;
      item.LoggerName = "name";
      item.LogLevel = LogLevel.Warn;
      item.Message = "the message";

      var exception = new Exception("test");
      item.Exception = exception;

      var timestamp = DateTimeOffset.Now.AddHours(-3);
      item.Timestamp = timestamp;
      
      var clone = item.Clone();
      Assert.AreEqual(999, clone.EventId);
      Assert.AreEqual("name", clone.LoggerName);
      Assert.AreEqual(LogLevel.Warn, clone.LogLevel);
      Assert.AreEqual("the message", clone.Message);
      Assert.AreSame(exception, clone.Exception);
      Assert.AreEqual(timestamp, clone.Timestamp);
    }


    /// <summary>
    /// 
    /// </summary>
    [TestMethod]
    public void Timestamp_Should_Be_Set_Automatically()
    {
      LogItem item = new LogItem();

      Assert.AreEqual(DateTime.Now.Day, item.Timestamp.Day);
      Assert.AreEqual(DateTime.Now.Hour, item.Timestamp.Hour);
      Assert.AreEqual(DateTime.Now.Minute, item.Timestamp.Minute);
    }
  }
}
